package com.zrrd.thread._05_priority;

import java.util.concurrent.Callable;
import java.util.concurrent.FutureTask;

/**
 * @author WanJl
 * @version 1.0
 * @title MyRunnable
 * @description
 * @create 2023/10/29 14:26
 */
public class MyCallable implements Callable<String> {
    @Override
    public String call() throws Exception {
        for (int i = 0; i < 50; i++) {
            System.out.println(Thread.currentThread().getName()+"----"+i);
        }

        return "线程执行完毕....";
    }

    public static void main(String[] args) {
        Thread t1 = new Thread(new FutureTask<>(new MyCallable()),"线程1");
        Thread t2 = new Thread(new FutureTask<>(new MyCallable()),"线程2");

        //设置线程的优先级 范围是1-10
        t1.setPriority(1);
        t2.setPriority(10);

        t1.start();
        t2.start();


        System.out.println(t1.getPriority());
    }
}
